package com.mindata.blockchain.block;

import java.util.HashMap;
import java.util.Map;

/**
 * @author wuweifeng wrote on 2018/3/20.
 */
public enum Operation {
    ADD(new Byte("1")),
    DELETE(new Byte("-1")),
    UPDATE(new Byte("2"));

    private Byte key;

    Operation(Byte key) {
        this.key = key;
    }

    public byte getKey() {
        return key;
    }


    private static final Map<Byte, Operation> ENUMMAP = new HashMap<>();

    static {
        for (Operation operation : Operation.values()) {
            ENUMMAP.put(operation.getKey(), operation);
        }
    }

    public static Operation fromValue(Byte key) {
        return ENUMMAP.get(key);
    }

}
